{%TEMPLATE->struct/head%}
{%TEMPLATE->struct/menu%}
<h2>User ([[htmlentities([[user.getUsername()]], ENT_QUOTES, "UTF-8")]])</h2>
{%TEMPLATE->struct/messages%}
<div class="card">
  <div class="table-responsive">
    <table class="table table-bordered">
		  <tr>
			  <th>User ID</th>
			  <td>[[user.getId()]]</td>
		  </tr>
		  <tr>
			  <th>Username</th>
			  <td>[[htmlentities([[user.getUsername()]], ENT_QUOTES, "UTF-8")]]</td>
		  </tr>
		  <tr>
			  <th>Email</th>
			  <td>[[user.getEmail()]]</td>
		  </tr>
		  <tr>
			  <th>Creation date</th>
			  <td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[user.getRegisteredSince()]])]]</td>
		  </tr>
		  <tr>
			  <th>Last login</th>
			  <td>[[date([[config.getVal(DConfig::TIME_FORMAT)]], [[user.getLastLoginDate()]])]]</td>
		  </tr>
		  <tr>
			  <th>Member of groups</th>
			  <td>
				  {{FOREACH group;[[accessGroups]]}}
					  <a href="groups.php?id=[[group.getId()]]">[[group.getGroupName()]]</a><br>
				  {{ENDFOREACH}}
				  {{IF [[sizeof([[accessGroups]])]] == 0}}
					  ---
				  {{ENDIF}}
			  </td>
		  </tr>
		  <tr>
			  <th>Enable/Disable user</th>
			  <td>
				  {{IF [[user.getIsValid()]] == 1}}
					  User is currently enabled
					  <form class='form-inline' action="users.php?id=[[user.getId()]]" method="post">
						  <input type='hidden' name='action' value='[[$DUserAction::DISABLE_USER]]'>
						  <input type='hidden' name='user' value='[[user.getId()]]'>
						  <input type="hidden" name="csrf" value="[[csrf]]">
						  <input type="submit" class='btn btn-warning' value="Disable">
					  </form>
				  {{ELSE}}
					  User is currently disabled
					  <form class='form-inline' action="users.php?id=[[user.getId()]]" method="post">
						  <input type='hidden' name='action' value='[[$DUserAction::ENABLE_USER]]'>
						  <input type='hidden' name='user' value='[[user.getId()]]'>
						  <input type="hidden" name="csrf" value="[[csrf]]">
						  <input type="submit" class='btn btn-success' value="Enable">
					  </form>
				  {{ENDIF}}
			  </td>
		  </tr>
		  <tr>
			  <th>Set users right group</th>
			  <td>
				  <form class='form-inline' action="users.php?id=[[user.getId()]]" method="post">
					  <input type='hidden' name='action' value='[[$DUserAction::SET_RIGHTS]]'>
					  <input type='hidden' name='user' value='[[user.getId()]]'>
					  <input type="hidden" name="csrf" value="[[csrf]]">
					  <select name='group' class='form-control' title="AccessLevel">
						  {{FOREACH group;[[groups]]}}
							  <option value='[[group.getId()]]'{{IF [[group.getId()]] == [[user.getRightGroupId()]]}} selected{{ENDIF}}>[[group.getGroupName()]]</option>
						  {{ENDFOREACH}}
					  </select>&nbsp;&nbsp;
            <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
				  </form>
			  </td>
		  </tr>
		  <tr>
			  <th>Set password</th>
			  <td>
				  <form class='form-inline' action="users.php?id=[[user.getId()]]" method="post">
					  <input type='hidden' name='action' value='[[$DUserAction::SET_PASSWORD]]'>
					  <input type='hidden' name='user' value='[[user.getId()]]'>
					  <input type='password' name='pass' class='form-control' title="Password">&nbsp;&nbsp;
					  <input type="hidden" name="csrf" value="[[csrf]]">
            <button type="submit" class='btn {{IF [[toggledarkmode]] > 0}}btn-primary{{ELSE}}btn-light{{ENDIF}}' data-toggle="tooltip" data-placement="top" title="Set"><i class="fas fa-save" aria-hidden="true"></i></button>
				  </form>
			  </td>
		  </tr>
		  <tr>
			  <th>Delete user</th>
			  <td>
          <form class='form-inline' action="users.php?id=[[user.getId()]]" onsubmit="if(!confirm('Do you really want to delete this user? This cannot be undone!')){return false;}" method="post">
            <input type='hidden' name='action' value='[[$DUserAction::DELETE_USER]]'>
            <input type='hidden' name='user' value='[[user.getId()]]'>
            <input type="hidden" name="csrf" value="[[csrf]]">
            <button type="submit" class='btn btn-danger' value="Delete" data-toggle="tooltip" data-placement="top" title="Delete"><i class="fas fa-trash" aria-hidden="true"></i></button>
          </form>
			  </td>
		  </tr>
	  </table>
  </div>
</div>
{%TEMPLATE->struct/foot%}
